package com.windoent.yugioh.help.recycle;

import android.content.Context;
import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.windoent.yugioh.utils.TDevice;


/**
 * author : robert
 * date   : 2021/5/17 15:55
 * desc   :
 * https://blog.csdn.net/lovext4098477/article/details/80419201?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_v2~rank_aggregation-1-80419201.pc_agg_rank_aggregation&utm_term=recyclerview+%E5%9D%87%E5%88%86&spm=1000.2123.3001.4430
 */
public class GridSpaceItemDecoration extends RecyclerView.ItemDecoration {
    private Context context;

    public GridSpaceItemDecoration(Context context) {
        this.context = context;
    }


    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
        if (parent.getChildAdapterPosition(view) % 11 != 10) {
            outRect.left = 0;
            outRect.right = TDevice.dp2px(context, -25);
        } else {
            outRect.left = 0;
            outRect.right = 0;
        }
    }
}
